<template>
	<!--消息-->
	<view class="community">
		<view class="head_bg" style="height: 280rpx;"></view> 
		<view v-if="index==0" v-for="(info,index) in list" :key="index" class="operating_box" style="margin-top:-230rpx;margin-bottom:20rpx;">
			<view class="flex padding-bottom-sm solid">
				<view class="flex-sub padding-left-lg padding-top-lg">
					<image src="../../../common/img/chongdianzhuang.png" style="width:200rpx;height:200rpx;"></image>
				</view>
				<view class="flex-treble text-left margin-left-sm">
					<view class="text-black text-bold text-xl padding-bottom-sm">{{info.notification_title}}</view>
					<view class="">
						<text style="font-size: 34rpx;color: #000000;">{{info.residential_quarters_name}}</text>
					</view>
					<view class="">
						<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
						<text class="text-df text-gray" style="vertical-align: middle;">{{info.residential_quarters_address}}</text>
					</view>
				</view>
			</view>
			<view class="padding-left-lg padding-top-lg">
				<view >
					<text class="text-left">终端编号：{{info.equipment_number}}
					<!-- <text v-if="info.socket_port==0" class="padding-left-xs">1号口</text>
					<text v-else class="padding-left-xs">2号口</text> -->
					</text>
					<text class="margin-right-lg" style="float: right;">{{info.notification_time}}</text>
				</view>
				<view class="margin-top-xs">
					<text class="text-left">充电信息：
					    <text class="text-red">{{info.notification_information}}</text>
					</text>
				</view>
			</view>
		</view>
		<view v-if="index>0" v-for="(info,index) in list" :key="index" class="operating_box" style="margin-bottom:20rpx;">
			<view class="flex padding-bottom-sm solid">
				<view class="flex-sub padding-left-lg padding-top-lg">
					<image src="../../../common/img/chongdianzhuang.png" style="width:200rpx;height:200rpx;"></image>
				</view>
				<view class="flex-treble text-left margin-left-sm">
					<view class="text-black text-bold text-xl padding-bottom-sm">{{info.notification_title}}</view>
					<view class="">
						<text style="font-size: 34rpx;color: #000000;">{{info.residential_quarters_name}}</text>
					</view>
					<view class="">
						<image class="ele_address_img" src="../../../common/img/dizhi_hui.png" mode=""></image>
						<text class="text-df text-gray" style="vertical-align: middle;">{{info.residential_quarters_address}}</text>
					</view>
				</view>
			</view>
			<view class="padding-left-lg padding-top-lg">
				<view >
					<text class="text-left">终端编号：{{info.equipment_number}}
					<!-- <text v-if="info.socket_port==0" class="padding-left-xs">1号口</text>
					<text v-else class="padding-left-xs">2号口</text>
					 --></text>
					<text class="margin-right-lg" style="float: right;">{{info.notification_time}}</text>
				</view>
				<view class="margin-top-xs">
					<text class="text-left">充电信息：
					    <text class="text-red">{{info.notification_information}}</text>
					</text>
				</view>
			</view>
		</view>
		<view class="text-black text-df text-center bg-white padding-sm padding-left-lg be-gray">
			{{loadingTxt}}   共({{list.length}}条记录)
		</view>
	</view>
</template>

<script>
	let page=1,timer=null
	export default {
		data() {
			return {
				loadingTxt:'加载更多',
				list:[],
			}
		},
		onLoad() {
			this.getList();
		},
		onShow() {
			page=1;
			this.getList();
		},
		methods: {
			getList(){
				let that=this;
				that.http.tokenreq({
					url: 'user/v1/messgae',
					data:{
						'pageindex':page
					}
				}).then((res) => {
					let e=res.data;
					console.log(e)
					if(e.code==0 && e.success){
						that.list=e.rows;
						page++;
					}else{
						uni.showToast({
							icon: 'none',
						    title: e.message
						});
					}
				})
			},
			getmorelist(){
				this.loadingTxt='加载中'
				let that=this;
				that.http.tokenreq({
					url: 'user/v1/messgae',
					data:{
						'pageindex':page
					}
				}).then((res) => {
					uni.hideLoading();
					let e=res.data;
					if(e.code==0 && e.success){
						if(e.rows.length==0){
							that.loadingTxt="已经加载全部";
							return;
						}
						that.list=that.list.concat(e.rows);
						page++;
					}else{
						uni.showToast({
							icon: 'none',
						    title: e.message
						});
					}
				})
			},
			onReachBottom() {
				//阻止重复加载
				if(timer !== null){
					clearTimeout(timer)
				}
				timer=setTimeout(()=>this.getmorelist(),500)
			},
		}
	}
</script>

<style>
    .head_bg{
		height:100rpx;
	}
</style>
